<?php

/**
 * This is the model class for table "reservator".
 *
 * The followings are the available columns in table 'reservator':
 * @property integer $ID_RESERVATOR
 * @property integer $ID_SMS
 * @property string $NAMA_RESERVATOR
 * @property string $EMAIL_RESERVATOR
 * @property string $ALAMAT_RESERVATOR
 * @property string $NO_HAPE_RESERVATOR
 *
 * The followings are the available model relations:
 * @property SmsOut $iDSMS
 * @property Transaksi[] $transaksis
 */
class Reservator extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Reservator the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'reservator';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('EMAIL_RESERVATOR','email'),
			array('ID_RESERVATOR, ID_SMS', 'numerical', 'integerOnly'=>true),
			array('NAMA_RESERVATOR', 'length', 'max'=>30),
			array('EMAIL_RESERVATOR', 'length', 'max'=>50),
			array('ALAMAT_RESERVATOR', 'length', 'max'=>100),
			array('NO_HAPE_RESERVATOR', 'length', 'max'=>15),
			array('NAMA_RESERVATOR, EMAIL_RESERVATOR, ALAMAT_RESERVATOR,NO_HAPE_RESERVATOR', 'required'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_RESERVATOR, ID_SMS, NAMA_RESERVATOR, EMAIL_RESERVATOR, ALAMAT_RESERVATOR, NO_HAPE_RESERVATOR', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'iDSMS' => array(self::BELONGS_TO, 'SmsOut', 'ID_SMS'),
			'transaksis' => array(self::HAS_MANY, 'Transaksi', 'ID_RESERVATOR'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_RESERVATOR' => 'Id Reservator',
			'ID_SMS' => 'Id Sms',
			'NAMA_RESERVATOR' => 'Nama Reservator',
			'EMAIL_RESERVATOR' => 'Email Reservator',
			'ALAMAT_RESERVATOR' => 'Alamat Reservator',
			'NO_HAPE_RESERVATOR' => 'No Hape Reservator',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_RESERVATOR',$this->ID_RESERVATOR);
		$criteria->compare('ID_SMS',$this->ID_SMS);
		$criteria->compare('NAMA_RESERVATOR',$this->NAMA_RESERVATOR,true);
		$criteria->compare('EMAIL_RESERVATOR',$this->EMAIL_RESERVATOR,true);
		$criteria->compare('ALAMAT_RESERVATOR',$this->ALAMAT_RESERVATOR,true);
		$criteria->compare('NO_HAPE_RESERVATOR',$this->NO_HAPE_RESERVATOR,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}